#ifndef __TIME_WRAPPER_H__
#define __TIME_WRAPPER_H__
#include <time.h>
#include <string>

#ifdef MY_NAMESPACE_BEGIN
MY_NAMESPACE_BEGIN
#endif

class TimeWrapper{
public:
	TimeWrapper();
	TimeWrapper(	const time_t& sec );
	TimeWrapper(	const struct tm& brokenDown );
	TimeWrapper(	const std::string& dateTimeString,
			const std::string& format="" );

	void SetTime(	const time_t& sec );
	void SetTime(	const struct tm& brokenDown );
	void SetTime( 	const std::string& dateTimeString,
			const std::string& format="");

	time_t GetTimeSec() const;
	const struct tm& GetTimeTm() const;
	std::string GetTimeStr( const std::string& format="") const;
	
	bool IsInited() const;

	void PrintTm( const std::string& prefix="" ) const;
private:
	void FillTmFromTimeT(	const time_t& second,
				struct tm& brokendown );

	void FillTimeTFromTm(	const struct tm& brokenDownConst,
				time_t& sec,
				struct tm& brokenDown );

	void FillTimeTFromStr(	const std::string& dateTimeString,
				const std::string& format,
				time_t& second,
				struct tm& brokenDown );

	void ConvertTmToStr(	const struct tm& brokemDown,
				std::string& timeStr,
				const std::string& format ) const;
private:
	time_t mSimpleTime;
	struct tm mBrokenDown;
	bool mbInited;
};

#ifdef MY_NAMESPACE_END
MY_NAMESPACE_END
#endif

#endif

